import request from "@/util/request";

const baseUrl = '/attrgroup/'
const attrUrl='/attrGroup/attribute/'

/*添加*/
export function add(data) {
    return request({
        method: 'post',
        url: baseUrl + 'add',
        data
    })
}
export function modifyGroup(data) {
    return request({
        method: 'put',
        url: baseUrl + 'modify/group',
        data
    })
}
export function delGroupList(data) {
    return request({
        method: 'delete',
        url: baseUrl + 'del/group/list',
        data
    })
}

/*通过三季分类获取属性分组信息*/
export function getAttrGroupByCategoryId(categoryId) {
    return request({
        method: 'get',
        url: baseUrl + `get/byCategoryId/${categoryId}`,
    })
}
/*通过三级分类获取属性*/
export function getAttrByCategoryId(categoryId,attrType){
    return request({
        method: 'get',
        url: attrUrl + `get/byCategoryId/${categoryId}/${attrType}`,
    })
}
/*通过关联的分组Id获取属性*/
export function getAttrByAttrGroupId(AttrGroupId){
    return request({
        method: 'get',
        url: attrUrl + `get/byAttrGroupId/${AttrGroupId}`,
    })
}
/*通过三级分类获取没有关联的属性*/
export function getNoAssoAttrByCategoryId(categoryId){
    return request({
        method: 'get',
        url: attrUrl + `get/noAsso/byCategoryId/${categoryId}`,
    })
}
export function addAttr(data) {
    return request({
        method: 'post',
        url: attrUrl + 'add',
        data
    })
}
export function addAssoAttrAndGroup(data) {
    return request({
        method: 'post',
        url: baseUrl + 'add/asso',
        data
    })
}
export function modifyAttrApi(data){
    return request({
        method: 'put',
        url: attrUrl + 'modify',
        data
    })
}

export function getSaleAttrByCategoryIdApi(category){
    return request({
        method: 'get',
        url: attrUrl + '/saleAttr/'+category,

    })
}
